// Author: Little09
// Problem: #3037. 「JOISC 2019 Day3」开关游戏
// Contest: LibreOJ
// URL: https://loj.ac/p/3037
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// Start Time: 2023-09-08 19:28:29
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mem(x) memset(x,0,sizeof(x))
#define endl "\n"
#define printYes cout << "Yes\n"
#define printYES cout << "YES\n"
#define printNo cout << "No\n"
#define printNO cout << "NO\n"
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define mkp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,j,k) for (int i=(j);i<=(k);i++)
#define per(i,j,k) for (int i=(j);i>=(k);i--)
mt19937 rnd(time(0));
template<class T>void chkmin(T&x,T y){x=min(x,y);}
template<class T>void chkmax(T&x,T y){x=max(x,y);}

const ll inf=1000000000000000000; 
//const ll inf=1000000000;
//const ll mod=998244353;
//const ll mod=1000000007;

const int N=1000005;
int n,m; 
int a[N],b[N];
int dp[N][3][2];

int main()
{
  freopen("hard.in","r",stdin);
  freopen("hard.out","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  cin >> n;
  rep(i,1,n)
  {
    char x;
    cin >> x;
    a[i]=x=='1';
  }
  rep(i,1,n)
  {
    char x;
    cin >> x;
    b[i]=x=='1';
  }
  rep(i,0,n) rep(j,0,2) rep(k,0,1) dp[i][j][k]=1e9;
  dp[0][2][0]=0;
  rep(i,1,n) rep(j,0,2) rep(k,0,1)
  {
    if (dp[i-1][j][k]==1e9) continue;
    rep(x,0,2) rep(y,0,1)
    {
      int u=a[i];
      if (x<=1) u=x;
      if (y==1) u^=1;
      if (u!=b[i]) continue;
      int c=dp[i-1][j][k]+(y==1&&k==0)+(x!=2&&x!=j);
      dp[i][x][y]=min(dp[i][x][y],c);
    }
  }
  int ans=1e9;
  rep(i,0,2) rep(j,0,1) chkmin(ans,dp[n][i][j]);
  cout << ans;
  return 0;
}